function displayTreeInfo( id, name, comment, divId ) {

    if( name.length > 40 ) { name = name.substr(0, 40) + '...'; }
    if( comment.length > 50 ) { comment = comment.substr(0, 50) + '...'; }

    var treeRow = makeEl('div').attr( { 'id': 'tree' + id, 'class': 'fullwidth', 'treeId': id } )
        .append( makeEl('div').attr( { 'class': 'width10 fLeft smallText' } )
                    .append( makeEl('div').attr( { 'class': 'center' } )
                                .append( makeEl('a').attr( { 'href' : '/' + globals.applicationName + '/default/viewer/' + id + '/' + globals.maxTips } ).text('view') ),
                             makeEl('div').attr( { 'class': 'center' } )
                                .append( makeEl('a').attr( { 'href' : 'javascript:void(0);' } ).click( function() { ajaxDeleteNewick(id) } ).text('delete') ) ),
                 makeEl('div').attr( { 'class': 'width30 fLeft center' } ).text(name),
                 makeEl('div').attr( { 'class': 'width60 fLeft center' } ).text(comment),
                 makeEl('div').attr( { 'class': 'clear' } ) );
    
    $('#' + divId).append(treeRow);
    
    if( divId == 'savedClades' ) {
        treeRow.addClass('savedCladeRow');
        treeRow.toggle( addSelectedSavedClade( treeRow, divId ), removeSelectedSavedClade( treeRow, divId ) );
    }
    
}

function addSelectedSavedClade( treeRow, divId ) { treeRow.addClass('selectedSavedClade'); checkSelectedSaved(divId); }
function removeSelectedSavedClade( treeRow, divId ) { treeRow.removeClass('selectedSavedClade'); checkSelectedSaved(divId); }

function newickFileSelected() {
    $('#newickString').hide();
    $('#newickFileSelectedNotice').removeClass('hide');
    $('#cancelNewickFileUploadLink').removeClass('hide');
    $('#shadowboxSubmitButton').unbind('click').click( submitFileUploader );
}

function submitFileUploader() { globals.uploader.submit(); }
function newickStringAjaxUpload() { ajaxAddNewick(); }

function showNewickStringUploadDialogue() {
    $('#newickString').show();
    $('#newickFileSelectedNotice').addClass('hide');
    $('#cancelNewickFileUploadLink').addClass('hide');
    $('#shadowboxSubmitButton').unbind('click').click( newickStringAjaxUpload );
}

function removeUserTree(id) { $('#tree'+id).fadeOut('slow', function() { $('#tree'+id).remove(); } ); }

function indexWindowOnLoad() {

    $('#treeListHeader').append(
        makeEl('div').attr( { 'class': 'fLeft rightMargin1' } ).text('Your trees'),
        makeEl('div').attr( { 'class': 'fRight smallText' } ).append(
            makeEl('a').attr( { 'href': 'javascript:void(0);' } ).click( shadowboxAddNewick ).text('Add Newick') ),
        makeEl('div').attr( { 'class': 'clear' } ) );

    
}
